
#ifndef _IIMenuItem_H_
#define _IIMenuItem_H_

#include <BMenu>
#include <BAction>
#include "IAlignItem.h"

namespace BWE
{
	class IMenuItem : public IAlignItem
	{
	public:
		inline IMenuItem() : IAlignItem(0)
		{

		}
		inline IMenuItem(BMenu* menu) : IAlignItem(menu)
		{
			this->menu = menu;
		}
		inline IMenuItem(BAction* action) : IAlignItem(action)
		{
			this->action = action;
		}
		inline IMenuItem(const IMenuItem& other) : IAlignItem(other)
		{
			menu = other.menu;
			action = other.action;
			arrowRect = other.arrowRect;
		}

		virtual void dispenseStyles(const BStyle* style);
		virtual void translateText(const BStyle* style);

		virtual void freshSize(const BFont* font, int width);
		virtual void freshRects();

		inline bool empty() const
		{
			return action.empty() && menu.empty();
		}
		inline bool enabled() const
		{
			if (action)
				return action->enabled();
			if (menu)
				return menu->enabled();
			return false;
		}

		inline bool operator == (const BObject* object) const
		{
			return action == object || menu == object;
		}
		inline bool operator == (const BAction* action) const
		{
			return this->action == action;
		}
		inline bool operator == (const BMenu* menu) const
		{
			return this->menu == menu;
		}

		BHolder<BMenu>		menu;
		BHolder<BAction>	action;
		BRect				arrowRect;
		BSize				expandSize;
		BRect				expandArea;
		BSize				shortcutSize;
		BRect				shortcutRect;
	};

}

#endif
